<!doctype html>



  


<html class="theme-next pisces use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="dubbo,thread,多线程," />





  <link rel="alternate" href="/atom.xml" title="crossoverJie's Blog" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.1" />






<meta name="description" content="前言最近个人事情比较多（搬家、换工作、短暂休息）所以一直也没有顾得上博客更新，恰好最近收到一封邮件提醒了我。

也是时候写一篇文章来聊聊参与开源项目的事（最近也确实进入了笔荒期）。
ps:第一次收到这样的中秋节礼物，加上 Dubbo 社区的活跃及阿里的重视度，还在做 PRC 或微服务技术选型的朋友可以考虑 Dubbo。">
<meta property="og:type" content="article">
<meta property="og:title" content="如何参与一个顶级开源项目">
<meta property="og:url" content="http://crossoverjie.top/2019/08/19/open source/ how to contribute open-source project/index.html">
<meta property="og:site_name" content="crossoverJie's Blog">
<meta property="og:description" content="前言最近个人事情比较多（搬家、换工作、短暂休息）所以一直也没有顾得上博客更新，恰好最近收到一封邮件提醒了我。

也是时候写一篇文章来聊聊参与开源项目的事（最近也确实进入了笔荒期）。
ps:第一次收到这样的中秋节礼物，加上 Dubbo 社区的活跃及阿里的重视度，还在做 PRC 或微服务技术选型的朋友可以考虑 Dubbo。">
<meta property="og:image" content="https://i.loli.net/2019/08/19/baUDOepui5qgKZE.jpg">
<meta property="og:image" content="https://i.loli.net/2019/08/19/GRemrwT94SFZgq1.jpg">
<meta property="og:image" content="https://i.loli.net/2019/08/19/tUyNi3qPdKWAIlT.jpg">
<meta property="og:image" content="https://i.loli.net/2019/08/19/QC1X4sTr8B6bquP.jpg">
<meta property="og:image" content="https://i.loli.net/2019/08/19/PaOn7wUrXRK8CEV.jpg">
<meta property="og:image" content="https://i.loli.net/2019/08/19/z2r3ghHUtawfJsc.jpg">
<meta property="og:image" content="https://i.loli.net/2019/08/19/BYQZoROTkPxSazL.jpg">
<meta property="og:image" content="https://i.loli.net/2019/08/19/8wI71aZvlYzdgOQ.jpg">
<meta property="og:image" content="https://i.loli.net/2019/08/19/JQYZb6Lcemw9jaA.jpg">
<meta property="og:image" content="https://i.loli.net/2019/08/19/CqDNrM4IJd8276R.jpg">
<meta property="og:image" content="https://i.loli.net/2019/08/19/I1WSzpism3UtkQJ.jpg">
<meta property="og:image" content="https://i.loli.net/2019/08/19/Odr91A6NxH3TUMe.jpg">
<meta property="og:updated_time" content="2019-08-18T17:33:03.643Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="如何参与一个顶级开源项目">
<meta name="twitter:description" content="前言最近个人事情比较多（搬家、换工作、短暂休息）所以一直也没有顾得上博客更新，恰好最近收到一封邮件提醒了我。

也是时候写一篇文章来聊聊参与开源项目的事（最近也确实进入了笔荒期）。
ps:第一次收到这样的中秋节礼物，加上 Dubbo 社区的活跃及阿里的重视度，还在做 PRC 或微服务技术选型的朋友可以考虑 Dubbo。">
<meta name="twitter:image" content="https://i.loli.net/2019/08/19/baUDOepui5qgKZE.jpg">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 555390,
      author: 'crossoverJie'
    }
  };
</script>




  <link rel="canonical" href="http://crossoverjie.top/2019/08/19/open source/ how to contribute open-source project/"/>

  <title> 如何参与一个顶级开源项目 | crossoverJie's Blog </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="en">

  








  <div style="display: none;">
    <script src="https://s6.cnzz.com/stat.php?id=1259025147&web_id=1259025147" type="text/javascript"></script>
  </div>





  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">crossoverJie's Blog</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">baller</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            Categories
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            About
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            Archives
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            Tags
          </a>
        </li>
      
        
        <li class="menu-item menu-item-photo">
          <a href="/favourite" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-photo"></i> <br />
            
            photo
          </a>
        </li>
      
        
        <li class="menu-item menu-item-jcsprout">
          <a href="https://crossoverjie.top/JCSprout/#/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-leaf"></i> <br />
            
            JCSprout
          </a>
        </li>
      
        
        <li class="menu-item menu-item-cicada">
          <a href="https://github.com/TogetherOS/cicada" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-github"></i> <br />
            
            cicada
          </a>
        </li>
      
        
        <li class="menu-item menu-item-cim">
          <a href="https://github.com/crossoverjie/cim" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-far fa-comment"></i> <br />
            
            CIM
          </a>
        </li>
      
        
        <li class="menu-item menu-item-vlog">
          <a href="https://space.bilibili.com/42339430" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-youtube"></i> <br />
            
            Vlog
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="#" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            Search
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup">
 <span class="search-icon fa fa-search"></span>
 <input type="text" id="local-search-input">
 <div id="local-search-result"></div>
 <span class="popup-btn-close">close</span>
</div>


    </div>
  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                如何参与一个顶级开源项目
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">Posted on</span>
            <time itemprop="dateCreated" datetime="2019-08-19T08:13:00+08:00" content="2019-08-19">
              2019-08-19
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">In</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/open-source/" itemprop="url" rel="index">
                    <span itemprop="name">open source</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2019/08/19/open source/ how to contribute open-source project/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count disqus-comment-count" data-disqus-identifier="2019/08/19/open source/ how to contribute open-source project/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          
             <span id="/2019/08/19/open source/ how to contribute open-source project/" class="leancloud_visitors" data-flag-title="如何参与一个顶级开源项目">
               &nbsp; | &nbsp;
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               <span class="post-meta-item-text">visitors </span>
               <span class="leancloud-visitors-count"></span>
              </span>
          

          
              &nbsp; | &nbsp;
              <span class="page-pv">本文总阅读量
              <span class="busuanzi-value" id="busuanzi_value_page_pv" ></span>次
              </span>
          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <p><img src="https://i.loli.net/2019/08/19/baUDOepui5qgKZE.jpg" alt=""></p>
<h1 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h1><p>最近个人事情比较多（搬家、换工作、短暂休息）所以一直也没有顾得上博客更新，恰好最近收到一封邮件提醒了我。</p>
<p><img src="https://i.loli.net/2019/08/19/GRemrwT94SFZgq1.jpg" alt=""></p>
<p>也是时候写一篇文章来聊聊参与开源项目的事（最近也确实进入了笔荒期）。</p>
<p>ps:第一次收到这样的中秋节礼物，加上 <code>Dubbo</code> 社区的活跃及阿里的重视度，还在做 <code>PRC</code> 或微服务技术选型的朋友可以考虑 <code>Dubbo</code>。</p>
<a id="more"></a>
<h1 id="参与开源"><a href="#参与开源" class="headerlink" title="参与开源"></a>参与开源</h1><p>现在具体来聊聊参与开源的事；</p>
<p>日常几乎所有的开发者都会享受到开源项目所带来的便利甚至是收益，受限于环境早在十几年前甚至几年前开源活动一直都是有国外开发者主导。</p>
<p>但这几年国内互联网公司逐渐国际化扩大影响力也很大程度的提高了我们的开发水平，以 <code>BAT</code> 为首出现了许多优秀的开源项目。</p>
<p>现在甚至参与开源项目还能另辟蹊径的拿到大厂 <code>offer</code>，所以其实不少朋友都想参与其中，可能这事给人的第一感觉就不太容易，所以现在还卡在第一步。</p>
<h2 id="具体步骤"><a href="#具体步骤" class="headerlink" title="具体步骤"></a>具体步骤</h2><p>以下是以我个人经验总结的几大步骤：</p>
<ul>
<li>发现问题或自荐 <code>feature</code> 。</li>
<li>fork 源码。</li>
<li>本地开发、自测。</li>
<li>发起 <code>pull request</code> 。</li>
<li>等待社区 <code>Code Review</code> 。</li>
<li>跟进社区意见调整代码。</li>
<li>审核通过，合并进 <code>master</code> 分支，完成本次贡献。</li>
</ul>
<p>下面我会结合最近一次参与 <code>Dubbo</code> 的流程来具体聊聊。</p>
<h3 id="发现问题或自荐-feature"><a href="#发现问题或自荐-feature" class="headerlink" title="发现问题或自荐 feature"></a>发现问题或自荐 feature</h3><p>首先第一步自然要搞清楚自己本次贡献的内容是什么？通常都是解决某个问题或者是提交一个新的 <code>feature</code> ；前者相对起来更加容易一些。</p>
<p>当然这个问题可以是自己使用过程中发现的，也可以是 Issues 列表中待解决的问题。</p>
<p>以本次为例，就是我在使用过程中所发现的问题，也提交了相关 <a href="https://github.com/apache/dubbo/issues/4556" target="_blank" rel="external">Issue</a> 并写了一篇文章记录并解决了该问题：<a href="https://crossoverjie.top/2019/07/05/troubleshoot/dubbo-start-slow/">What？一个 Dubbo 服务启动要两个小时！</a></p>
<p>值得注意的是在提交 Issue 之前最好是先在 Issue 列表中通过关键字检索下是否已经有相关问题，避免重复。</p>
<p>同时提交之后也许社区会进行跟进，被打上 <code>invalid</code> 标签认为不是问题，或者是使用姿势不对也是有可能的。</p>
<h3 id="fork-源码，本地开发"><a href="#fork-源码，本地开发" class="headerlink" title="fork 源码，本地开发"></a>fork 源码，本地开发</h3><p>当确定这是一个待修复的问题时就可以着手开发了。</p>
<p>首先第一步自然是将源码拷贝一份到自己仓库中。</p>
<p><img src="https://i.loli.net/2019/08/19/tUyNi3qPdKWAIlT.jpg" alt=""></p>
<p>接着只需要 clone 自己仓库中的源码到本地进行开发。</p>
<p>先回顾下我遇到的这个问题。</p>
<p><img src="https://i.loli.net/2019/08/19/QC1X4sTr8B6bquP.jpg" alt=""></p>
<p>简单来说就是启动 <code>Dubbo</code> 服务非常缓慢，经过定位是 <code>main</code> 线程阻塞在了获取本机 ip 处。</p>
<p>所以当时我提出的方案是：在获取本机 ip 时加上超时时间，一旦超时便抛出异常或者是再次重试，但起码得有日志方便用户定位问题。</p>
<p>问题是主线程会一直阻塞在此处 <code>InetAddress.getLocalHost().getHostAddress()</code>，但又需要知道它阻塞了多久才好判断是否超时。</p>
<p>所以只能再额外开启一个线程，定时去检测 <code>main</code> 线程是否已经完成任务了，以下便是我第一次 pr 的内容。</p>
<p><img src="https://i.loli.net/2019/08/19/PaOn7wUrXRK8CEV.jpg" alt=""><br><img src="https://i.loli.net/2019/08/19/z2r3ghHUtawfJsc.jpg" alt=""></p>
<p>这次的重点不是讨论这里具体的技术细节，所以简单说下步骤：</p>
<ul>
<li>额为声明了大小为 1 的线程池。</li>
<li>再声明了一个 <code>volatile</code> 标志用于判断主线程是否有完成任务。</li>
<li>声明了一个 condition 用于新线程做等待。</li>
<li>最后只需要运行这个线程用于判断这个标志即可。</li>
</ul>
<h3 id="如何自测"><a href="#如何自测" class="headerlink" title="如何自测"></a>如何自测</h3><p>开发完成后下一步就是自测，由于这类项目是作为一个基础包依赖于其他的项目才能运行的，所以通常我们还得新建一个项目来配合做全流程测试（单测除外）。</p>
<p>这里我觉得还是有几个小技巧值得注意。</p>
<p>第一个是版本号；因为在本地测试，所以需要使用 <code>mvn clean install</code> 将包安装到本地才能在其他项目中依赖进去进行测试。</p>
<p>但由于我们从官方拉出来的代码版本都已经发布到了 maven 中央仓库中（不管是 release 还是 snapshot），所以我们本地仓库中肯定已经存在这几个版本的 jar 包。</p>
<p>一旦我们执行 <code>mvn clean install</code> 将自己修改的代码安装到本地时，大概率是会出问题的（也可能是我姿势不对），这样就会导致新建的项目中依赖不了自己新增的代码。</p>
<p>所以我通常的做法是修改版本号，这个版本号是从来没有被官方发布到中央仓库中的，可以确保自己新增的代码会以一个全新版本安装到本地，这样我们再依赖这个版本进行测试即可。</p>
<blockquote>
<p>不过再提交时得注意不要把这个版本号提交上去了。</p>
</blockquote>
<h3 id="发起-pull-request"><a href="#发起-pull-request" class="headerlink" title="发起 pull request"></a>发起 pull request</h3><p>自测完成后便可发起 <code>pull request</code> 了，不要大意，这里还得有一个地方需要注意，那就是代码换行符的问题。</p>
<p>一旦换行符与源仓库的不一致时，<code>git</code> 会认为这次修改是删除后重来的，这样会给 <code>code review</code> 带来巨大的麻烦。</p>
<p><img src="https://i.loli.net/2019/08/19/BYQZoROTkPxSazL.jpg" alt=""></p>
<p>就像这样，明明我改动的行数并不多，但 <code>git</code> 确认为你是推翻了重来，导致审核起来根本不知道你改了哪些地方。</p>
<p>最简单的方法就是设置自己 <code>git</code> 的全局配置，可以参考<a href="http://kuanghy.github.io/2017/03/19/git-lf-or-crlf" target="_blank" rel="external">这里</a>。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"># 提交时转换为LF，检出时转换为CRLF</div><div class="line">git config --global core.autocrlf true</div><div class="line"></div><div class="line"># 提交时转换为LF，检出时不转换</div><div class="line">git config --global core.autocrlf input</div><div class="line"></div><div class="line"># 提交检出均不转换</div><div class="line">git config --global core.autocrlf false</div></pre></td></tr></table></figure>
<p><img src="https://i.loli.net/2019/08/19/8wI71aZvlYzdgOQ.jpg" alt=""></p>
<p>确认没问题后便可点击这里发起 pull request，后面按照引导执行即可。</p>
<p>当然各个项目之间还会有自己定制的贡献流程，最好就是查看官方的贡献指南。</p>
<p><a href="http://dubbo.apache.org/en-us/docs/developers/contributor-guide/new-contributor-guide_dev.html" target="_blank" rel="external">http://dubbo.apache.org/en-us/docs/developers/contributor-guide/new-contributor-guide_dev.html</a></p>
<h3 id="Code-Review"><a href="#Code-Review" class="headerlink" title="Code Review"></a>Code Review</h3><p><code>pr</code> 发起后便可等待社区审核了。</p>
<p>在这过程中要充分和社区进行交流，有可能你的方案和社区的想法并不一致。</p>
<p>比如像我这次：</p>
<p><img src="https://i.loli.net/2019/08/19/JQYZb6Lcemw9jaA.jpg" alt=""><br><img src="https://i.loli.net/2019/08/19/CqDNrM4IJd8276R.jpg" alt=""><br>最终通过沟通加上自己后面的思考觉得还是社区的方案更加轻便合理一些，达成一致之后社区便将这次 pr 合并进 master 中。</p>
<p>其实整个过程我觉得最有意义的便是 <code>code review</code> 的过程，所有人都可以参与其中头脑风暴，其中也不乏技术大牛，不知不觉便能学到不少东西。</p>
<h2 id="类似案例"><a href="#类似案例" class="headerlink" title="类似案例"></a>类似案例</h2><p>虽然我之前的方案没有被采纳，但类似的用法（一个线程监控其他线程）还是不少，正好在 <code>Dubbo</code> 中也有用到。</p>
<p>便是其中核心的服务调用，默认情况下对使用者来说这看起来是一个同步调用，也就是说消费方会等待 PRC 执行完毕后才会执行后续逻辑。</p>
<p>但其实在底层这就是一个 <code>TCP</code> 网络包的发送过程，<strong>本身就是异步的</strong>。</p>
<p>只是 <code>Dubbo</code> 在你不知道的情况下做了异步转同步，这样看起来就像是一个同步方法。</p>
<p><img src="https://i.loli.net/2019/08/19/I1WSzpism3UtkQJ.jpg" alt=""></p>
<p>如图中的红框部分，<code>Dubbo</code> 自身调用了 <code>get()</code> 方法用于同步获取服务提供者的返回结果。</p>
<p><img src="https://i.loli.net/2019/08/19/Odr91A6NxH3TUMe.jpg" alt=""></p>
<p>逻辑其实也挺简单，和我上文的方案类似，只是这里的 <code>isDone()</code> 函数返回的是是否已经拿到了服务提供者的返回值而已。</p>
<h1 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h1><p>本次总结了参与开源的具体步骤，其实也挺简单；就如官方所说哪怕是提个 Issue，修改一个错别字都算是参与，所以不要想的太难。</p>
<p>最后还简单分析了 Dubbo 调用过程中的异步转同步的过程，掌握这些操作对自己平时开发也是很有帮助的。</p>
<p><strong>你的点赞与分享是对我最大的支持</strong></p>

      
    </div>

    <div>
      
        
<div id="wechat_subscriber" style="display: block； padding: 10px 0; margin: 20px auto; width: 100%; text-align: center">
    <img id="wechat_subscriber_qcode" src="/uploads/weixinfooter1.jpg" alt="crossoverJie wechat" style="width: 200px; max-width: 100%;"/>
    <div>我很有眼光！</div>
</div>

      
    </div>

    <div>
      
        
  <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
    <div>请我吃🍗</div>
    <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
      <span>赏</span>
    </button>
    <div id="QR" style="display: none;">
      
        <div id="wechat" style="display: inline-block">
          <img id="wechat_qr" src="/weixin-reward-image.jpg" alt="crossoverJie WeChat Pay"/>
          <p>微信打赏</p>
        </div>
      
      
        <div id="alipay" style="display: inline-block">
          <img id="alipay_qr" src="/alipay-reward-image.jpg" alt="crossoverJie Alipay"/>
          <p>支付宝打赏</p>
        </div>
      
    </div>
  </div>


      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/dubbo/" rel="tag">#dubbo</a>
          
            <a href="/tags/thread/" rel="tag">#thread</a>
          
            <a href="/tags/多线程/" rel="tag">#多线程</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2019/07/24/framework-design/sharding-db-03/" rel="next" title="一次难得的分库分表实践">
                <i class="fa fa-chevron-left"></i> 一次难得的分库分表实践
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2019/09/10/cs/not easy emoji/" rel="prev" title="不要小看小小的 emoji 表情😂">
                不要小看小小的 emoji 表情😂 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          

  <p>热评文章</p>
  <div class="ds-top-threads" data-range="weekly" data-num-items="4"></div>


          
  <div class="comments" id="comments">
    
      <div id="disqus_thread">
        <noscript>
          Please enable JavaScript to view the
          <a href="//disqus.com/?ref_noscript">comments powered by Disqus.</a>
        </noscript>
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            Overview
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/uploads/crossoverjie.jpg"
               alt="crossoverJie" />
          <p class="site-author-name" itemprop="name">crossoverJie</p>
          <p class="site-description motion-element" itemprop="description">You never know what you can do till you try.</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">116</span>
              <span class="site-state-item-name">posts</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">45</span>
                <span class="site-state-item-name">categories</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">109</span>
                <span class="site-state-item-name">tags</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/crossoverJie" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://www.jianshu.com/users/e2d07947c112/latest_articles" target="_blank" title="简书">
                  
                    <i class="fa fa-fw fa-book"></i>
                  
                  简书
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://juejin.im/user/576d4aaf7db2a20054ea4544" target="_blank" title="掘金">
                  
                    <i class="fa fa-fw fa-bookmark"></i>
                  
                  掘金
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://twitter.com/crossoverJie" target="_blank" title="Twitter">
                  
                    <i class="fa fa-fw fa-twitter"></i>
                  
                  Twitter
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              友情链接
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="http://wuchong.me" title="Jark's Blog" target="_blank">Jark's Blog</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://tengj.top" title="嘟嘟独立博客" target="_blank">嘟嘟独立博客</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://yemengying.com/" title="Giraffe Home" target="_blank">Giraffe Home</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://blog.jamespan.me/" title="潘小鶸(ruò)" target="_blank">潘小鶸(ruò)</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://fangjian0423.github.io/" title="Format's Notes" target="_blank">Format's Notes</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://yuzhouwan.com/" title="Benedict Jin" target="_blank">Benedict Jin</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://blog.didispace.com/" title="程序猿DD" target="_blank">程序猿DD</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://blog.52itstyle.vip/" title="小柒博客" target="_blank">小柒博客</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://cmsblogs.com/" title="Java技术驿站" target="_blank">Java技术驿站</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://vim.ink/" title="vim 教程网" target="_blank">vim 教程网</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://www.jitwxs.cn" title="jitwxs" target="_blank">jitwxs</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.javaboy.org" title="江南一点雨" target="_blank">江南一点雨</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="http://www.liangsonghua.me" title="松花皮蛋的黑板报" target="_blank">松花皮蛋的黑板报</a>
                </li>
              
                <li class="links-of-blogroll-item">
                  <a href="https://www.fi-ads.com" title="Future iDeal" target="_blank">Future iDeal</a>
                </li>
              
            </ul>
          </div>
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#前言"><span class="nav-number">1.</span> <span class="nav-text">前言</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#参与开源"><span class="nav-number">2.</span> <span class="nav-text">参与开源</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#具体步骤"><span class="nav-number">2.1.</span> <span class="nav-text">具体步骤</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#发现问题或自荐-feature"><span class="nav-number">2.1.1.</span> <span class="nav-text">发现问题或自荐 feature</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#fork-源码，本地开发"><span class="nav-number">2.1.2.</span> <span class="nav-text">fork 源码，本地开发</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#如何自测"><span class="nav-number">2.1.3.</span> <span class="nav-text">如何自测</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#发起-pull-request"><span class="nav-number">2.1.4.</span> <span class="nav-text">发起 pull request</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Code-Review"><span class="nav-number">2.1.5.</span> <span class="nav-text">Code Review</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#类似案例"><span class="nav-number">2.2.</span> <span class="nav-text">类似案例</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#总结"><span class="nav-number">3.</span> <span class="nav-text">总结</span></a></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2016 - 
  <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">crossoverJie</span>
</div>

<div class="powered-by">
  Powered by <a class="theme-link" href="http://hexo.io">Hexo</a>
</div>

<div class="theme-info">
  Theme -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Pisces
  </a>
</div>

        

<div class="busuanzi-count">

  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv"><i class="fa fa-user"></i><span class="busuanzi-value" id="busuanzi_value_site_uv"></span>人数</span>
  

  
    <span class="site-pv">您是第<span class="busuanzi-value" id="busuanzi_value_site_pv"></span>位童鞋</span>
  
  
</div>



        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.1"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.0.1"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.1"></script>



  



  

    <script type="text/javascript">
      var disqus_shortname = 'crossoverjie';
      var disqus_identifier = '2019/08/19/open source/ how to contribute open-source project/';
      var disqus_title = "如何参与一个顶级开源项目";
      var disqus_url = 'http://crossoverjie.top/2019/08/19/open source/ how to contribute open-source project/';

      function run_disqus_script(disqus_script){
        var dsq = document.createElement('script');
        dsq.type = 'text/javascript';
        dsq.async = true;
        dsq.src = '//' + disqus_shortname + '.disqus.com/' + disqus_script;
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
      }

      run_disqus_script('count.js');
      
        run_disqus_script('embed.js');
      
    </script>
  




  
  
  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
       search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body").append('<div class="popoverlay">').css('overflow', 'hidden');
      $('.popup').toggle();

    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
    'use strict';
    $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
            // get the contents from search data
            isfetched = true;
            $('.popup').detach().appendTo('.header-inner');
            var datas = $( "entry", xmlResponse ).map(function() {
                return {
                    title: $( "title", this ).text(),
                    content: $("content",this).text(),
                    url: $( "url" , this).text()
                };
            }).get();
            var $input = document.getElementById(search_id);
            var $resultContent = document.getElementById(content_id);
            $input.addEventListener('input', function(){
                var matchcounts = 0;
                var str='<ul class=\"search-result-list\">';                
                var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                $resultContent.innerHTML = "";
                if (this.value.trim().length > 1) {
                // perform local searching
                datas.forEach(function(data) {
                    var isMatch = true;
                    var content_index = [];
                    var data_title = data.title.trim().toLowerCase();
                    var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                    var data_url = data.url;
                    var index_title = -1;
                    var index_content = -1;
                    var first_occur = -1;
                    // only match artiles with not empty titles and contents
                    if(data_title != '' && data_content != '') {
                        keywords.forEach(function(keyword, i) {
                            index_title = data_title.indexOf(keyword);
                            index_content = data_content.indexOf(keyword);
                            if( index_title < 0 && index_content < 0 ){
                                isMatch = false;
                            } else {
                                if (index_content < 0) {
                                    index_content = 0;
                                }
                                if (i == 0) {
                                    first_occur = index_content;
                                }
                            }
                        });
                    }
                    // show search results
                    if (isMatch) {
                        matchcounts += 1;
                        str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                        var content = data.content.trim().replace(/<[^>]+>/g,"");
                        if (first_occur >= 0) {
                            // cut out 100 characters
                            var start = first_occur - 20;
                            var end = first_occur + 80;
                            if(start < 0){
                                start = 0;
                            }
                            if(start == 0){
                                end = 50;
                            }
                            if(end > content.length){
                                end = content.length;
                            }
                            var match_content = content.substring(start, end);
                            // highlight all keywords
                            keywords.forEach(function(keyword){
                                var regS = new RegExp(keyword, "gi");
                                match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                            });
                            
                            str += "<p class=\"search-result\">" + match_content +"...</p>"
                        }
                        str += "</li>";
                    }
                })};
                str += "</ul>";
                if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
                if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
                $resultContent.innerHTML = str;
            });
            proceedsearch();
        }
    });}

    // handle and trigger popup window;
    $('.popup-trigger').mousedown(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };

    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".popoverlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>

  

  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
  <script>AV.initialize("Qv6ckEtL1pe3PJD10qoOLKtg-gzGzoHsz", "NXiHFodQfmI8oxkK6IThhjrF");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  
<script type="text/javascript" src="/js/src/particle.js" count="50" zindex="-2" opacity="1" color="0,104,183"></script>
</body>
</html>
